home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CD-ROM Magazine 28 Bonus
/
CDRomMagazine-SoftKey-ArtPassion-FrenchVersion-Win31Mac.bin
/
data
/
crmixpl.dir
/
00085_Script_COLOR WHEEL PLAY
< prev
next >
Wrap
Text File
|
1996-05-07
|
9KB
|
269 lines
-- ---------------------------------------------------------------
-- Handler addColorToGuess (1) adds the clicked color to the list of
-- colors clicked, (2) mixes the color with the user's guess, and
-- (3) checks if the color the user mixed is correct.
on addColorToGuess whichColor
updatePrimaryUsed(whichColor)
addColorToAnswerCombination(whichColor)
changeAnswerColor
checkColorWheelResult
end
-- ---------------------------------------------------------------
-- Handler addColorToAnswerCombination adds the given color to the
-- combination of colors clicked (stored as a string in the global
-- variable answerCombination - of the form BxRzYw where x is the
-- number of times blue was clicked, z is the number of times red
-- was clicked, and w is the number of times yellow was clicked).
on addColorToAnswerCombination whichColor
global answerCombination
if whichColor = "B" then
set whichChar = 2
else if whichColor = "R" then
set whichChar = 4
else if whichColor = "Y" then
set whichChar = 6
end if
set numClickedSoFar = value(char whichChar of answerCombination)
set numClickedSoFar = numClickedSoFar + 1
put string(numClickedSoFar) into char whichChar of answerCombination
end
-- ---------------------------------------------------------------
-- Handler changeAnswerColor changes the color of the user's guess
-- to the given color by first setting the foreColor and backColor
-- of guessSprite to the mixedColor represented by answerCombination.
-- PalleteNumbers is a global variable containing a list of all
-- possible combinations of blues, reds and yellows and the pallete
-- number representing the combination. The colors are listed
-- in boolean form starting with B0R0Y1 and ending in B3R3Y3. The
-- following formula can be used to determine the line number used
-- for any given answerCombination: (B*16) + (R*4) + Y.
on changeAnswerColor mixedColor
global palleteNumbers, guessSprite, answerCombination
set palleteLine = (16*value(char 2 of answerCombination)) + (4*value(char 4 of answerCombination)) + value(char 6 of answerCombination)
set newPalleteNumber = value(word 2 of line palleteLine of palleteNumbers)
set the foreColor of sprite guessSprite = newPalleteNumber
set the backColor of sprite guessSprite = newPalleteNumber
updateStage
end
-- ---------------------------------------------------------------
-- Handler checkColorWheelResult checks if the user correctly mixed
-- the colors to get the answer color. If so, the handler adds the
-- mixed color to the color wheel and sets the game with a new color.
-- If not, the global variable answerCombination is set to the mixed color.
-- This allows the user to make colors such as greenYellow from 2 yellows
-- and blue and not just from green and yellow.
on checkColorWheelResult mixedColor
global guessSprite, answerSprite, answerPalleteNum
if the backColor of sprite guessSprite = answerPalleteNum then
beep
addColorToWheel
startTimer
repeat while the timer < 40
nothing
end repeat
-- checkGameOver
getNextColor
end if
end
-- ---------------------------------------------------------------
-- Handler addColorToWheel adds the color of the given sprite to
-- the color wheel by setting the visible property of the sprite
-- to TRUE.
on addColorToWheel
global answerCombination
set colorSprite = answerCombination & "Sprite"
if the visible of sprite value(colorSprite) = FALSE then
set the visible of sprite value(colorSprite) = TRUE
updateStage
end if
end
-- ---------------------------------------------------------------
-- Handler getNextColor takes the next color randomly from the global
-- variable possibleColorsList (property list where the name of each
-- property is a color and the value of each property is the pallete
-- number of the color).
on getNextColor
global answerSprite, answerPalleteNum
global possibleColorsList
clearAnswer
if count(possibleColorsList) > 0 then
set answerColorPosition = random(count(possibleColorsList))
set answerColorName = getPropAt(possibleColorsList,answerColorPosition)
set answerPalleteNum = getProp(possibleColorsList, answerColorName)
-- delete color user has to guess from the list
deleteProp (possibleColorsList, answerColorName)
-- add new possible colors to possibleColorsList
updatePossibleColorsList(answerColorName)
set the backColor of sprite answerSprite = answerPalleteNum
set the foreColor of sprite answerSprite = answerPalleteNum
clearPrimaryUsed
updateStage
else
winColorWheelGame
end if
end
-- ---------------------------------------------------------------
-- Handler clickTryAgain is called when the user clicks on the try
-- again button
on clickTryAgain
activateButton(the clickOn)
clearAnswer
end
-- ---------------------------------------------------------------
-- Handler clearAnswer is called either when the user clicks the
-- clear button or when the user correctly mixes the colors to
-- get the answer color. This handler resets the color of the user's
-- guess to white and resets the global variable answerCombination
-- (that stores the colors the user clicked) to the empty string.
on clearAnswer
global answerCombination, guessSprite
-- change the color of their guess back to white
clearPrimaryUsed
set the backColor of sprite guessSprite = 0
set the foreColor of sprite guessSprite = 255 -- black outline
updateStage
set answerCombination = "B0R0Y0"
end
-- ---------------------------------------------------------------
-- Handler updatePossibleColorsList updates the global variable
-- (property list) possibleColorsList by adding new makable
-- colors to the list (i.e. if the user just created B1Y1 (green) and
-- green was added to the color wheel, B2Y1 and B1Y2 will be added
-- to possibleColorsList). Each time a color is added to the color
-- wheel, 1 or 2 new colors are added to possibleColorsList (the new
-- color mixed with 1 or both of the 2 primary colors used to make it)
on updatePossibleColorsList newlyAddedColor
global possibleColorsList
set newColors = field "newColors"
repeat with i = 1 to the number of lines in newColors
if (item 1 of line i of newcolors = newlyAddedColor) then
repeat with j = 2 to the number of items in line i of newColors
addProp (possibleColorsList, word 1 of item j of line i of newColors, value(word 2 of item j of line i of newColors))
end repeat -- j
exit repeat -- i
end if
end repeat
end
-- ---------------------------------------------------------------
-- Handler updatePrimaryUsed updates the global variables keeping
-- record of the number of primary colors used so far.
on updatePrimaryUsed whichColor
global numBlue, numRed, numYellow
global numBSprite, numRSprite, numYSprite
set whichSprite = value("num" & whichColor & "Sprite")
set numUsed = value(char 1 of the name of cast the castNum of sprite whichSprite)
set numUsed = numUsed + 1
if (numUsed > 3) then
doUsedTooMany(whichColor)
clearAnswer
abort -- addColorToGuess
else
set newCast = numUsed & whichColor
set the castNum of sprite whichSprite = the number of cast newCast
updateStage
end if
end
-- ---------------------------------------------------------------
-- Handler clearPrimaryUsed resets to 0 the global variables keeping
-- track of the number of primary colors used so far.
on clearPrimaryUsed
global numBlue, numRed, numYellow
global numBSprite, numRSprite, numYSprite
set numBlue = 0
set numRed = 0
set numYellow = 0
set the castNum of sprite numBSprite = the number of cast "0B"
set the castNum of sprite numRSprite = the number of cast "0R"
set the castNum of sprite numYSprite = the number of cast "0Y"
-- stage is updated when this handler is called so it
-- doesn't ha